//@ts-ignore
import { debounce } from "./debounce";
import { ref, onUnmounted, onMounted, readonly } from "vue";

export function useinnerhehight(): {
    readonly value: number;
} {
    const height = ref(window.innerHeight);
    const listener = debounce(() => {
        requestAnimationFrame(() => {
            height.value = window.innerHeight;
        });
    });
    onMounted(() => {
        window.addEventListener("resize", listener);
    });
    onUnmounted(() => {
        window.removeEventListener("resize", listener);
        listener.cancel();
    });
    return readonly(height);
}
